package nl.hanze.designpatterns.Views;

import nl.hanze.designpatterns.Controllers.LoginController;
import nl.hanze.designpatterns.Controllers.QnAController;
import nl.hanze.designpatterns.Controllers.SaurusController;
import nl.hanze.designpatterns.Controllers.TicketController;
import nl.hanze.designpatterns.Models.MainModel;
import nl.hanze.designpatterns.Views.Login.LoginScreen;
import nl.hanze.designpatterns.Views.QnA.QnAScreen;
import nl.hanze.designpatterns.Views.Ticket.TicketScreen;
import nl.hanze.designpatterns.Views.Saurus.SaurusScreen;

import javax.swing.*;

/**
 * bleep
 *
 * Created by Aron on 18-9-2014.
 */
public class MainScreen extends javax.swing.JFrame {

    //private JPanel mainPanel;
    private MainModel mainModel;
    public MainScreen() {

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Ticket program");
        setSize(800, 600);
        setLocationRelativeTo(null);

        mainModel = new MainModel();

        changeView("login");

    }

    public void changeView(String view) {
        System.out.println("[INFO]test1");
        JPanel newScreen = null;
        switch(view)
        {
            case "login":
                System.out.println("[SCREEN]login");
                LoginController loginController = new LoginController(this, mainModel);
                newScreen =  new LoginScreen(loginController, mainModel);

                break;
            case "ticket":
                System.out.println("[SCREEN]ticket");
                TicketController ticketController = new TicketController(this, mainModel);
                newScreen = new TicketScreen(ticketController, mainModel);
                break;
            case "QnA":
                System.out.println("[SCREEN]QnA");
                QnAController qnaController = new QnAController(this, mainModel);
                newScreen = new QnAScreen(qnaController, mainModel);
                break;
            default:
                changeView("login");
        }
        if (newScreen != null) {
            getContentPane().removeAll();
            getContentPane().add(newScreen);
            pack();
        }

        System.out.println("[INFO]test2");
        this.setVisible(true);
    }
}
